﻿using AutoMapper;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using WidgetsDesign.API.Dtos;
using WidgetsDesign.API.Models;
using WidgetsDesign.API.Services;

namespace WidgetsDesign.API.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class WidgetsListsController : ControllerBase
    {
        private readonly IWidgetsListRepository _widgetsListRepository;
        private readonly IMapper _Mapper;
        public WidgetsListsController(IWidgetsListRepository widgetsListRepository, IMapper mapper)
        {
            _widgetsListRepository = widgetsListRepository;
            _Mapper = mapper;
        }
        [HttpGet]
        public async Task<IActionResult> GetWidgetList()
        {
            var result = await _widgetsListRepository.GetWidgetsListsAsync();
            if (result == null)
            {
               return Ok(new { code = 200, data = Array.Empty<object>() });
            }
            return Ok(new { code = 200, data = result });
        }
    }
}